home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Lines Curves and Area Fills / BetterPieChart / BetterPieChart.cs next >
Encoding:
Text File  |  2001-01-15  |  931 b   |  30 lines

  1. //---------------------------------------------
  2. // BetterPieChart.cs ⌐ 2001 by Charles Petzold
  3. //---------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class BetterPieChart: PieChart
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new BetterPieChart());
  13.      }
  14.      public BetterPieChart()
  15.      {
  16.           Text = "Better " + Text;
  17.      }
  18.      protected override void DrawPieSlice(Graphics grfx, Pen pen, 
  19.                                           Rectangle rect,
  20.                                           float fAngle, float fSweep)
  21.      {
  22.           float fSlice = (float)(2 * Math.PI * (fAngle + fSweep / 2) / 360);
  23.  
  24.           rect.Offset((int)(rect.Width  / 10 * Math.Cos(fSlice)),
  25.                       (int)(rect.Height / 10 * Math.Sin(fSlice)));
  26.  
  27.           base.DrawPieSlice(grfx, pen, rect, fAngle, fSweep);
  28.      }
  29. }
  30.